#include <SPI.h>
#include <nRF24L01.h>+
#include <RF24.h>

RF24 radio(7, 8);
const byte address[6] = "00001";
char text[32] ="";
void LED_CLODE()
{
digitalWrite(2,HIGH);
digitalWrite(4,HIGH);
digitalWrite(A0,HIGH);
digitalWrite(9,HIGH);
}
void LED_HALF()
{
digitalWrite(2,HIGH);
digitalWrite(4,LOW);
digitalWrite(A0,LOW);
digitalWrite(9,HIGH);
}
void LED_OFF()
{
digitalWrite(2,LOW);
digitalWrite(4,LOW);
digitalWrite(A0,LOW);
digitalWrite(9,LOW);
}

void setup() {
//rf24部分
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
//灯光部分
pinMode(2,OUTPUT);
pinMode(4,OUTPUT);
pinMode(A0,OUTPUT);
pinMode(9,OUTPUT);
LED_OFF();
}

void loop() {
if(radio.available()){
radio.read(&text, sizeof(text));
if(text[0]=='A')
{
LED_CLODE();
delay(20);
text[32] ="";
delay(10);
}
if(text[0]=='B')
{
LED_HALF();
delay(20);
text[32] ="";
delay(10);
}
if(text[0]=='C')
{
LED_OFF();
delay(20);
text[32] ="";
delay(10);
}
}

}
